package com.cskaoyan.exception;

import com.cskaoyan.model.vo.BaseRespVo;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

@ControllerAdvice
public class ValueExceptionHandler {

    @ExceptionHandler(ValueException.class)
    @ResponseBody
    public BaseRespVo valueException(ValueException v) {
        String message = v.getMessage();
        String word = v.getWord();
        return BaseRespVo.error(402, "年轻人价格:\"" + word + "\"" + message + "（别写一堆负号，前端有bug，显示刷新就好了）");
    }

    @ExceptionHandler(ShipSnException.class)
    @ResponseBody
    public BaseRespVo valueException(ShipSnException s) {
        String message = s.getMessage();
        String word = s.getWord();
        return BaseRespVo.error(402, "这一串：\"" + word + "\"不对劲，" + message);
    }


}
